package com.pedro.streamer.manager;


import android.annotation.SuppressLint;
import android.graphics.Color;
import android.net.Uri;

import com.pedro.encoder.input.gl.render.filters.MagnifierFilter;
import com.pedro.encoder.input.gl.render.filters.RippleFilterRender;
import com.pedro.encoder.input.gl.render.filters.TornadoFilter;
import com.pedro.encoder.input.gl.render.filters.WaveFilter;
import com.pedro.encoder.input.gl.render.filters.ZoomFilter;
import com.pedro.encoder.input.gl.render.filters.object.ImageObjectFilterRender;
import com.pedro.encoder.utils.gl.TranslateTo;
import com.pedro.library.view.OpenGlView;
import com.pedro.streamer.BmiBaseApp;
import com.pedro.streamer.R;
import com.pedro.streamer.model.ImageObjectFilterModel;
import com.pedro.streamer.utils.FileUtils;

import java.util.ArrayList;

public class VideoArrManager {


    public static VideoArrManager instance;

    public ArrayList<Uri> videoArr = new ArrayList<>();
    public OpenGlView openGlView;

    public int volume = 100;
    private TornadoFilter tornadoFilter;//龙卷风
    private MagnifierFilter magnifierFilter;//放大镜
    private WaveFilter waveFilter;//动感虚影
    private RippleFilterRender rippleFilterRender;//波浪
    private ZoomFilter zoomFilter;
    private ArrayList<ImageObjectFilterModel> imageObjectFilterRenders;
    private ImageObjectFilterRender imageObjectFilterRender;
    public Boolean isTornadoFilter = false;//龙卷风
    public Boolean isMagnifierFilter = false;//放大镜
    public Boolean isWaveFilter = false;//动感虚影
    public Boolean isRippleFilterRender = false;//波浪
    public Boolean isZoomFilterRender = false;//运镜

    public int breatheSpeed = 200;
    public int breatheMargin = 5;

    public int tornadoMargin = 1;

    public int magnifierMargin = 20;

    public int waveMargin = 1;

    public int rippleMargin = 1;
    public int rippleSpeed = 1;

    public static VideoArrManager shareInstance() {

        if (instance == null) {
            instance = new VideoArrManager();
        }
        return instance;

    }


    public void setVideoArr(ArrayList<Uri> videoArr) {
        this.videoArr = videoArr;
    }

    public ArrayList<Uri> getVideoArr() {
        return videoArr;
    }

    public void setVolume(int volume) {
        this.volume = volume;
    }

    public int getVolume() {
        return volume;
    }


    public void setOpenGlView(OpenGlView openGlView) {
        this.openGlView = openGlView;

        imageObjectFilterRenders = new ArrayList<>();

        tornadoFilter = new TornadoFilter();
        tornadoFilter.setTornadoRadius(tornadoMargin);
        tornadoFilter.setTornadoStrength(2);


        magnifierFilter = new MagnifierFilter();
        magnifierFilter.setRadius(magnifierMargin);

        waveFilter = new WaveFilter();
        waveFilter.setWaveAmplitude(waveMargin/10.0f);

        rippleFilterRender = new RippleFilterRender();
        rippleFilterRender.setSpeed(rippleSpeed);
        rippleFilterRender.setAmplitude(rippleMargin);

        zoomFilter = new ZoomFilter();
    }

    public OpenGlView getOpenGlView() {
        return openGlView;
    }


    public TornadoFilter getTornadoFilter() {
        return tornadoFilter;
    }

    public WaveFilter getWaveFilter() {
        return waveFilter;
    }

    public MagnifierFilter getMagnifierFilter() {
        return magnifierFilter;
    }

    public RippleFilterRender getRippleFilterRender() {
        return rippleFilterRender;
    }

    public ZoomFilter getZoomFilterRender() {
        return zoomFilter;
    }

    public ImageObjectFilterRender getImageObjectFilterRender() {
        return imageObjectFilterRender;
    }

    public void setBreatheMargin(int breatheMargin) {
        this.breatheMargin = breatheMargin;
    }

    public int getBreatheMargin() {
        return breatheMargin;
    }

    public void setBreatheSpeed(int breatheSpeed) {
        this.breatheSpeed = breatheSpeed;
    }

    public int getBreatheSpeed() {
        return breatheSpeed;
    }

    public void setTornadoMargin(int tornadoMargin) {
        this.tornadoMargin = tornadoMargin;
    }

    public int getTornadoMargin() {
        return tornadoMargin;
    }


    public int getMagnifierMargin() {
        return magnifierMargin;
    }

    public void setMagnifierMargin(int magnifierMargin) {
        this.magnifierMargin = magnifierMargin;
    }

    public void setWaveMargin(int waveMargin) {
        this.waveMargin = waveMargin;
    }

    public int getWaveMargin() {
        return waveMargin;
    }

    public void setRippleMargin(int rippleMargin) {
        this.rippleMargin = rippleMargin;
    }

    public int getRippleMargin() {
        return rippleMargin;
    }


    public void setRippleSpeed(int rippleSpeed) {
        this.rippleSpeed = rippleSpeed;
    }

    public int getRippleSpeed() {
        return rippleSpeed;
    }

    public ArrayList<ImageObjectFilterModel> getImageObjectFilterRenders() {
        return imageObjectFilterRenders;
    }
}
